package com.ebo.httpcall4j.springboot3.autoconfig;

import com.ebo.httpcall4j.core.log.HttpCallLogService;
import com.ebo.httpcall4j.springboot3.HttpCallLogInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web MVC配置类，用于注册自定义的拦截器。
 */
public class HttpCallWebMvcConfigurer implements WebMvcConfigurer {

    private final HttpCallLogService logService;

    public HttpCallWebMvcConfigurer(HttpCallLogService logService) {
        this.logService = logService;
    }

    /**
     * 添加拦截器到拦截器注册表。
     *
     * @param registry 拦截器注册表。
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new HttpCallLogInterceptor(logService));
    }
}